#include "DataStruct.fxh"
#include "States.fxh"
#include "commonFunc.fxh"

float4x4 mInvWorldViewProj;         //1D texture for color bar
TextureCube	EMTex;
float fExpo; //exposure parameter
float fGamma; //gamma parameter

VS_OUTPUT_SKYBOX RenderSkyboxVS(VS_INPUT_SKYBOX Input)
{
	VS_OUTPUT_SKYBOX Output;
    Output.Pos = Input.Pos;
    Output.Tex = normalize( mul(Input.Pos, mInvWorldViewProj) );
    
    return Output;
}

float4 RenderSkyboxPS(VS_OUTPUT_SKYBOX In):SV_TARGET
{
	float4 color = EMTex.Sample(LinearSampler,In.Tex);
	return float4(SimpleTMandGamma(color.xyz,fExpo,fGamma), color.w);
}

//--------------------------------------------------------------------------------------
// Renders quad 
//--------------------------------------------------------------------------------------
technique11 RenderSkybox
{
    pass P0
    {        
		//SetRasterizerState(RenderMesh_RS);
		SetDepthStencilState(DisableDepthTestWrite,0);
        SetVertexShader(CompileShader(vs_5_0, RenderSkyboxVS()));
		SetGeometryShader( NULL );
        SetPixelShader(CompileShader(ps_5_0, RenderSkyboxPS())); 
    }
}
